package mt.client;

import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class TopPanel extends JPanel{

	/**
	 * The TopPanel was thought to aggregate all the functions related to connection
	 *
	 * @author group 55
	 */

	/**
	 *
	 */
	private static final long serialVersionUID = -7072594641903762862L;
	/**
	 * Nickname of the client
	 */
	private final JLabel nicknameLabel;
	/**
	 * responsible for performing a connection to server
	 */
	private final JButton connect;
	/**
	 * responsible for performing a disconnection to server
	 */
	private final JButton disconnect;

	/**
	 *
	 * @param nicknameLabel       responsible for showing the attributes of the last order received
	 * @param connect             responsible for showing when the order was received
	 * @param disconnect           responsible for performing a disconnection to server
	 */
	public TopPanel(String nickname){
		nicknameLabel = new JLabel("Nickname: " + nickname);
		connect = new JButton("Connect");
		disconnect = new JButton("Disconnect");
		config();
	}

	/**
	 * procedure responsible for the layout configuration
	 */
	private void config(){
		setLayout(new GridBagLayout());
		GridBagConstraints gbc = new GridBagConstraints();
		gbc.fill = GridBagConstraints.BOTH;

		gbc.weightx = 0.7;
		add(nicknameLabel,gbc);

		gbc.weightx = 0.3;
		add(connect,gbc);
		add(disconnect,gbc);
	}

	public JButton getConnectButton() {
		return connect;
	}

	public JButton getDisconnectButton() {
		return disconnect;
	}


}
